//
//  YYTextViewController.m
//  UI
//
//  Created by apple on 2017/7/3.
//  Copyright © 2017年 apple. All rights reserved.
//

#import "YYTextViewController.h"
#import <YYText.h>
@interface YYTextViewController ()

@end

@implementation YYTextViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.view.backgroundColor = [UIColor whiteColor];
    
    YYLabel *label = [[YYLabel alloc] initWithFrame:CGRectMake(100, 200, 50, 50)];
    label.text = @"haha";
    label.textColor = [UIColor blueColor];
    label.font = [UIFont systemFontOfSize:20];
    label.lineBreakMode = NSLineBreakByTruncatingHead;
    
//    [self.view addSubview:label];
    
    [self attributeStr];
}

//属性文本
- (void)attributeStr
{
    //1.创建一个属性文本
    NSMutableAttributedString *attributeStr = [[NSMutableAttributedString alloc] initWithString:@"旧时月色,算几番照我,梅边吹笛?唤起玉人,不管清寒与攀摘.何逊而今渐老,都忘却,春风词笔.但怪得,竹外疏花,春冷入瑶席.江国,正寂寂.叹寄与路遥,夜雪初积.翠尊易泣,红萼无言耿相忆.常记曾携手处,千树压.梅湖寒碧,又片片吹尽也,何时得见? "];
    
    //2.为文本设置属性
    attributeStr.yy_font = [UIFont boldSystemFontOfSize:18.0];
    [attributeStr yy_setColor:[UIColor blueColor] range:NSMakeRange(0, 1)];
    attributeStr.yy_lineSpacing = 20.0;
    
    //3.赋值给YYLabel
    YYLabel *yyLabel = [[YYLabel alloc] init];
    yyLabel.attributedText = attributeStr;
    yyLabel.numberOfLines = 0;
    yyLabel.frame = CGRectMake(0.0, 64.0, self.view.bounds.size.width, 500.0);
    [self.view addSubview:yyLabel];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
